 #include "TcpServer.hpp"
#include "Http.hpp"

void Usage(std::string proc)
{
    std::cout << "Usage:\n\t" << proc << " serverport\n"
              << std::endl;
}

std::shared_ptr<HttpResponse> Login(std::shared_ptr<HttpRequest> req)
{
	LOG(DEBUG, "=========================\n");
	std::string userdata;
    	if(req->Method() == "GET")
    	{
        	userdata = req->A
    	}
	else if(req->Method() == "POST")
	{
		userdata = req->Text();
	}
	else
	{}


	LOG(DEBUG, "enter data handler, data is : %s\n", userdata.c_str());

	auto response = Factory::BuildHttpResponose();
    response->AddStatusLine(200, "OK");
    response->AddHeader("Content-Type", "text/html");
    response->AddText("<html><h1>handler data done</h1></html>");
    LOG(DEBUG, "=========================\n");
    return response;

}

// ./tcpclient serverip serverport
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(1);
    }
    uint16_t port = std::stoi(argv[1]);
    HttpServer httpserver;
    TcpServer tcpsvr(port, std::bind(&HttpServer::HandlerHttpRequest, &httpserver, std::placeholders::_1));

    tcpsvr.Loop();


    return 0;
}
